<template>
  <div class="box m_t_20" v-if="records.length>0">
    <div>业务文件生成</div>
    <div v-for="(item, index) in records" :key="index" class="box1">
      <div class="d_f a_i_c">
        <img src="../../assets/file.png" alt="" class="img" >
        <span class="m_l_5 docName">{{ item.docName }}</span>
      </div>
      <div class="d_f j_c_s_b m_t_10">
        <div></div>
        <div>
          <a :href="item.tpUrl" class="size" v-if="item.tpUrl">模版下载</a>
          <a :href="item.url" class="m_l_10 size" v-if="item.url">预览</a>
        </div>
      </div>
    </div>
  </div>
</template>

<script lang='ts'>
import { defineComponent, reactive, toRefs, onMounted } from 'vue'
import { docList,batchDocList} from '../../api/agent'
import { useRoute, } from 'vue-router'
import {singleStrokeFilingType} from './data'
export default defineComponent({
  name: '',
  props:{
  type:{
    type:String,
    default: '',
  }
  },
  setup(props:any) {
    const data:singleStrokeFilingType = reactive({
      records: [],


    })
    const route = useRoute()

    onMounted(() => {
      methods.getData()
    })
    const methods = {
      getData() {
        if(props.type){
          batchDocList({batchNo:route.query.batchNo as string,nodeId:route.query.nodeId as string}).then((res:any)=>{
            data.records = res
          })
        }else{
          docList({ nodeId: route.query.nodeId as string, projectId: route.query.projectId as string }).then((res: any) => {
           console.log(res);
          data.records = res
        })
        }
       
      },
      downloadFile(url:string){
        //  window.open(url, '_blank')
      }
    }
    return {
      ...toRefs(data), ...methods
    }
  }
})
</script>
<style scoped lang='scss'>
.box{
  background: linear-gradient(178deg, #F5F9FF 0%, #FFFFFF 62%);
    box-sizing: border-box;
    border: 1px solid;
    border-image: linear-gradient(168deg, rgba(155, 188, 235, 0.5) 1%, rgba(102, 142, 197, 0) 94%) 1;
    border-radius: 6px;
    box-shadow: 5px 5px 5px -2px rgba(9, 20, 29, 0.03);
    width: 100%;
    padding: 15px;
}
.box1 {
  width: calc(100% - 20px);
  height: 72px;
  padding: 10px;
  border-radius: 4px;
  background: #fff;
  margin-top: 20px;
  .size{
    cursor: pointer;
    color: #1878FF;
  }
  .docName{
    font-size: 13px;
  }
  .img{
    width: 20px;
    height: 18px;
  }
}
</style>